home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsICaret.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  5KB  |  158 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsICaret_h__
  39. #define nsICaret_h__
  40.  
  41. #include "nsISupports.h"
  42. #include "nsCOMPtr.h"
  43. #include "nsCoord.h"
  44.  
  45. struct nsRect;
  46. struct nsPoint;
  47.  
  48. class nsIRenderingContext;
  49. class nsIFrame;
  50. class nsIView;
  51. class nsIPresShell;
  52. class nsISelection;
  53. class nsIDOMNode;
  54.  
  55. // IID for the nsICaret interface
  56. // c2ba7b60-ccbf-4f2b-8bf7-07493bbf3377
  57. #define NS_ICARET_IID \
  58. { 0xc2ba7b60, 0xccbf, 0x4f2b, \
  59.   { 0x8b, 0xf7, 0x07, 0x49, 0x3b, 0xbf, 0x33, 0x77 } }
  60.  
  61. class nsICaret: public nsISupports
  62. {
  63. public:
  64.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICARET_IID)
  65.  
  66.   enum EViewCoordinates {
  67.       eTopLevelWindowCoordinates,
  68.       eRenderingViewCoordinates,
  69.       eClosestViewCoordinates,
  70.       eIMECoordinates
  71.     };
  72.  
  73.   NS_IMETHOD Init(nsIPresShell *inPresShell) = 0;
  74.   NS_IMETHOD Terminate() = 0;
  75.   
  76.   NS_IMETHOD GetCaretDOMSelection(nsISelection **aDOMSel) = 0;
  77.   NS_IMETHOD SetCaretDOMSelection(nsISelection *aDOMSel) = 0;
  78.  
  79.   /** SetCaretVisible will set the visibility of the caret
  80.    *  @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it
  81.    */
  82.   NS_IMETHOD SetCaretVisible(PRBool inMakeVisible) = 0;
  83.  
  84.   /** GetCaretVisible will get the visibility of the caret
  85.    *  @param inMakeVisible PR_TRUE it is shown, PR_FALSE it is hidden
  86.    */
  87.   NS_IMETHOD GetCaretVisible(PRBool *outMakeVisible) = 0;
  88.  
  89.   /** SetCaretReadOnly set the appearance of the caret
  90.    *  @param inMakeReadonly PR_TRUE to show the caret in a 'read only' state,
  91.    *  PR_FALSE to show the caret in normal, editing state
  92.    */
  93.   NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly) = 0;
  94.  
  95.   /** GetCaretCoordinates
  96.    *  Get the position of the caret in coordinates relative to the typed specified (aRelativeToType).
  97.    *  If the selection is collapsed, this returns the caret location
  98.    *    and true in outIsCollapsed.
  99.    *  If the selection is not collapsed, this returns the location of the focus pos,
  100.    *    and false in outIsCollapsed.
  101.    */
  102.   NS_IMETHOD GetCaretCoordinates(EViewCoordinates aRelativeToType, nsISelection *aDOMSel, nsRect *outCoordinates, PRBool *outIsCollapsed, nsIView **outView) = 0;
  103.  
  104.   /** Erase Caret
  105.    *  this will erase the caret if its drawn and reset drawn status
  106.    */
  107.   NS_IMETHOD EraseCaret() = 0;
  108.  
  109.   NS_IMETHOD SetVisibilityDuringSelection(PRBool aVisibilityDuringSelection) = 0;
  110.   
  111.   /** DrawAtPosition
  112.    *  
  113.    *  Draw the caret explicitly, at the specified node and offset.
  114.    *  To avoid drawing glitches, you should call EraseCaret()
  115.    *  after each call to DrawAtPosition().
  116.    *
  117.    **/
  118.   NS_IMETHOD DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset) = 0;
  119.  
  120. };
  121.  
  122. nsresult
  123. NS_NewCaret(nsICaret** aInstancePtrResult);
  124.  
  125.  
  126. // handy stack-based class for temporarily disabling the caret
  127.  
  128. class StCaretHider
  129. {
  130. public:
  131.                StCaretHider(nsICaret* aSelCon)
  132.                : mWasVisible(PR_FALSE), mCaret(aSelCon)
  133.                {
  134.                  if (mCaret)
  135.                  {
  136.                    mCaret->GetCaretVisible(&mWasVisible);
  137.                    if (mWasVisible)
  138.                      mCaret->SetCaretVisible(PR_FALSE);
  139.                  }
  140.                }
  141.                
  142.                ~StCaretHider()
  143.                {
  144.                  if (mCaret && mWasVisible)
  145.                    mCaret->SetCaretVisible(PR_TRUE);
  146.                  // nsCOMPtr releases mPresShell
  147.                }
  148.  
  149. protected:
  150.  
  151.     PRBool                  mWasVisible;
  152.     nsCOMPtr<nsICaret>  mCaret;
  153. };
  154.  
  155.  
  156. #endif  // nsICaret_h__
  157.  
  158.